package com.harboursoftware.xstorage.unit.web

import com.harboursoftware.xstorage.web.PostPolicy;
import org.junit.Test 

class PostPolicyTest {
    
    def json = """
            { "expiration": "2007-12-01T12:00:00.000Z",
              "conditions": [
                {"bucket": "johnsmith"},
                ["starts-with", "\$key", "user/eric/"],
                {"acl": "public-read"},
                {"success_action_redirect": "http://johnsmith.s3.amazonaws.com/successful_upload.html"},
                ["starts-with", "\$Content-Type", "image/"],
                {"x-amz-meta-uuid": "14365123651274"},
                ["starts-with", "\$x-amz-meta-tag", ""]
              ]
            }
"""
    
    void test_fromBase64Json() {
    }
    
    @Test
    void test_fromJson() {
        def policy = PostPolicy.fromJson(json)
        def expiration = Calendar.getInstance()
        expiration.clear()
        expiration.set(2007, 11, 1, 12, 0, 0)
        println expiration.time
        println policy.expiration

    }
}
